from typing import Optional

from pydantic import BaseModel, ConfigDict, Field, model_validator
from pydantic.alias_generators import to_camel
from typing import Optional

from module_admin.annotation.pydantic_annotation import as_query


class StrategyTradebookModel(BaseModel):
    """
    策略交易登记簿表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='登记簿id')
    name: Optional[str] = Field(default=None, description='策略实例名称')
    price: Optional[float] = Field(default=0, description='价格')
    buy: Optional[int] = Field(default=0, description='委托买入')
    sell: Optional[int] = Field(default=0, description='委托卖出')
    bought: Optional[int] = Field(default=0, description='已经买入')
    sold: Optional[int] = Field(default=0, description='已经卖出')
    create_time: Optional[str] = Field(default=None, description='创建时间')
    update_time: Optional[str] = Field(default=None, description='更新时间')


@as_query
class StrategyTradebookQueryModel(BaseModel):
    """
    策略交易登记簿管理不分页查询模型
    """
    model_config = ConfigDict(alias_generator=to_camel)
    
    name: Optional[str] = Field(default=None, description='策略实例名称')


@as_query
class StrategyTradebookPageQueryModel(BaseModel):
    """
    策略交易登记簿管理分页查询模型
    """
    model_config = ConfigDict(alias_generator=to_camel)

    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')
    name: Optional[str] = Field(default=None, description='策略实例名称')


class DeleteStrategyTradebookModel(BaseModel):
    """
    删除策略交易登记簿模型
    """

    ids: list[int] = Field(description='登记簿id列表')